﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OgilvyOne.BLL;
using System.Data;

public partial class allergy_doctor_doctor_area : System.Web.UI.Page
{
    protected int pageNum = 1;
    protected int pageCount = 0;
    protected int total;
    protected string titles;
    protected string meta_kwords;
    protected string meta_desc;
    protected void Page_Load(object sender, EventArgs e)
    {
        //this.doctor_rpt.DataSource = BLLArticleInfo.getIndexTopDocrot();
        //this.doctor_rpt.DataBind();

        //妈妈要知道
        this.doKnow_rpt.DataSource = BLLArticleInfo.selectc("5", "doKnow", "1");
        this.doKnow_rpt.DataBind();

        DataTable seodt = BLLArticleInfo.getSeoInfo("205");
        foreach (DataRow seorows in seodt.Rows)
        {
            titles = seorows["Columntitle"].ToString();
            meta_kwords = seorows["ColumnKeyword"].ToString();
            meta_desc = seorows["ColumnDesc"].ToString();
        }


        total = BLLArticleInfo.countFAQ();
        if ((total % 10) == 0)
        {
            pageCount = total / 10;
        }
        else
        {
            pageCount = (total / 10) + 1;
        }

        if (!IsPostBack)
        {
            //loadArticle();
            PagerControl1.LoadData = new LoadDataHandler(this.LoadPagingArticle);
            PagerControl1.PagingParams.TotalCount = total;
            PagerControl1.PagingParams.PageSize = 10;
            PagerControl1.PagingParams.CurrentPageIndex = 0;
            LoadPagingArticle(PagerControl1.PagingParams);
        }
    }
    protected void page_Command(object sender, CommandEventArgs e)
    {
        if (ViewState["pageNum"] != null)
        {
            pageNum = Convert.ToInt32(ViewState["pageNum"].ToString());
        }
        if (e.CommandName.Equals("next") || e.CommandName.Equals("nextp"))
        {
            pageNum++;
            if (pageNum > 1 && pageNum <= pageCount)
            {
                ViewState["pageNum"] = pageNum;
                loadArticle();
            }
        }
        else
        {
            pageNum--;
            if (pageNum >= 1 && pageNum <= pageCount)
            {
                ViewState["pageNum"] = pageNum;
                loadArticle();
            }
        }

    }
    protected void LoadPagingArticle(PagingParameter pagingParams)
    {
        DataTable dt = BLLArticleInfo.GetFAQlist(pagingParams.PageSize.ToString(), (pagingParams.CurrentPageIndex * 10).ToString());
        this.Faqlist_rpt.DataSource = dt;
        this.Faqlist_rpt.DataBind();

        this.gini_rpt.DataSource = BLLArticleInfo.selArticle("88");
        this.gini_rpt.DataBind();

        this.fda_rpt.DataSource = BLLArticleInfo.selArticle("89");
        this.fda_rpt.DataBind();
    }
    protected void loadArticle()
    {

        if (ViewState["pageNum"] != null)
        {
            pageNum = Convert.ToInt32(ViewState["pageNum"].ToString());
        }
        DataTable dt = BLLArticleInfo.GetFAQlist("10", ((pageNum - 1) * 10).ToString());
        this.Faqlist_rpt.DataSource = dt;
        this.Faqlist_rpt.DataBind();

        this.gini_rpt.DataSource = BLLArticleInfo.selArticle("88");
        this.gini_rpt.DataBind();

        this.fda_rpt.DataSource = BLLArticleInfo.selArticle("89");
        this.fda_rpt.DataBind();

    }
}
